import cv2
import numpy as np

img = cv2.imread("C:\\Users\\86191\\Pictures\\Saved Pictures\\Camera Roll\\kc.jpg")
h,w = img.shape[:2]
gary1 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gary2 = np.zeros((h,w),np.uint8)
for i in range(h):
    for j in range(w):
        gary2[i,j] = 0.114*int(img[i,j,0])+0.587*int(img[i,j,1])+0.299*int(img[i,j,2])


cv2.imshow("img",img)
cv2.imshow("Gary1",gary1)
cv2.imshow("Gary2",gary2)
cv2.waitKey(0)
cv2.destroyAllWindows()